package com.whfc.mach.manager.warn;

import com.whfc.mach.enums.AppMachWarnRuleType;
import com.whfc.mach.manager.warn.impl.*;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * @author sun_guodong
 * @description
 * @date 2021-01-09
 */
@Component
public class AppWarnManagerFactory {
    /**
     * 设备硬件检测
     */
    @Resource(name = "machDeviceWarnCheckManagerImpl")
    private MachDeviceWarnCheckManagerImpl machDeviceWarnCheckManagerImpl;
    /**
     * 设备发动机检测
     */
    @Resource(name = "machEngineWarnCheckManagerImpl")
    private MachEngineWarnCheckManagerImpl machEngineWarnCheckManagerImpl;
    /**
     * 设备电子围栏检测
     */
    @Resource(name = "machFenceWarnCheckManagerImpl")
    private MachFenceWarnCheckManagerImpl machFenceWarnCheckManagerImpl;
    /**
     * 设备倾角检测
     */
    @Resource(name = "machRotationWarnCheckManagerImpl")
    private MachRotationWarnCheckManagerImpl machRotationWarnCheckManagerImpl;
    /**
     * 设备速度检测
     */
    @Resource(name = "machSpeedWarnCheckManagerImpl")
    private MachSpeedWarnCheckManagerImpl machSpeedWarnCheckManagerImpl;
    /**
     * 设备工作状态检测
     */
    @Resource(name = "machWorkStateWarnCheckManagerImpl")
    private MachWorkStateWarnCheckManagerImpl machWorkStateWarnCheckManagerImpl;
    /**
     * 设备牵引力检测
     */
    @Resource(name = "machForceWarnCheckManagerImpl")
    private MachForceWarnCheckManagerImpl machForceWarnCheckManagerImpl;

    public AppWarnManager getWarnCheckManager(Integer ruleType) {
        AppMachWarnRuleType appMachWarnRuleType = AppMachWarnRuleType.parseValue(ruleType);
        switch (appMachWarnRuleType) {
            case DEVICE:
                return machDeviceWarnCheckManagerImpl;
            case ENGINE:
                return machEngineWarnCheckManagerImpl;
            case FENCE:
                return machFenceWarnCheckManagerImpl;
            case IDLE:
            case STOP:
            case WORK:
                return machWorkStateWarnCheckManagerImpl;
            case SPEED:
                return machSpeedWarnCheckManagerImpl;
            case ROTATION:
                return machRotationWarnCheckManagerImpl;
            case FORCE:
                return machForceWarnCheckManagerImpl;
            default:
                return null;
        }
    }

}
